package com.stylefeng.guns.modular.front.controller;

import com.stylefeng.guns.core.base.controller.FrontBaseController;
import com.stylefeng.guns.core.base.tips.SuccessTip;
import com.stylefeng.guns.modular.flagglory.service.*;
import com.stylefeng.guns.modular.front.dto.AnswerResultDto;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by IntelliJ IDEA.
 * User: xinqi
 * Date: 2018/2/6
 * Time: 11:37
 */
@RestController
@RequestMapping("/front/question")
public class FrontQuestionController extends FrontBaseController {

    @Autowired
    private IGloryUserService userService;
    @Autowired
    private IQuestionService questionService;

    @RequestMapping(value = "/getRobotQuestionInfo", method = RequestMethod.GET)
    @ApiOperation("获取机器人对战信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "答题人id", dataType = "int", paramType = "query", defaultValue = "1"),
            @ApiImplicitParam(name = "divisionId", value = "段位id", dataType = "int", paramType = "query", defaultValue = "1")})
    public Object getRobotQuestionInfo(Integer userId, Integer divisionId) throws Exception {
        return new SuccessTip(questionService.getRobotQuestionInfo(userId, divisionId));
    }

    @RequestMapping(value = "/getResult", method = RequestMethod.POST)
    @ApiOperation(value = "获取答题结果")
    @ApiImplicitParam(name = "answerResultDto", value = "答题内容", dataType = "AnswerResultDto", paramType = "AnswerResultDto")
    public Object getResult(@RequestBody AnswerResultDto answerResultDto) throws Exception {
        return new SuccessTip(userService.getResult(answerResultDto));
    }

    @RequestMapping(value = "/getQuestionInfo", method = RequestMethod.GET)
    @ApiOperation("获取对战信息（机器人或者镜像）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "答题人id", dataType = "int", paramType = "query", defaultValue = "1"),
            @ApiImplicitParam(name = "divisionId", value = "段位id", dataType = "int", paramType = "query", defaultValue = "1")})
    public Object getQuestionInfo(Integer userId, Integer divisionId) throws Exception {
        return new SuccessTip(questionService.getQuestionInfo(userId, divisionId));
    }

}
